package test;

public class Display implements ITest{

    @Override
    public void openDevice() {
        System.out.println("打开显示器");
    }

    @Override
    public void closeDevice() {
        System.out.println("关闭显示器");
    }

    public void testDevice(ITest iTest) {
        iTest.openDevice();
        if(iTest instanceof Mouse) {
            Mouse mouse = (Mouse) iTest;
            mouse.click();
        }else if(iTest instanceof KeyBoard){
            KeyBoard keyBoard = (KeyBoard) iTest;
            keyBoard.click();
        }
        iTest.closeDevice();
    }

    public static void main(String[] args) {
        Display display = new Display();
        display.openDevice();
        display.testDevice(new Mouse());
        display.testDevice(new KeyBoard());
        display.closeDevice();
    }
}
